﻿namespace LuckyAssetManagerContrib.Configuration
{
	using System.Configuration;

	/// <summary>
	/// Configuration settings of file cache manager
	/// </summary>
	public sealed class AssetFileCacheManagerElement : ConfigurationElement
	{
		/// <summary>
		/// File cache duration (in minutes)
		/// </summary>
		[ConfigurationProperty("fileCacheDurationInMinutes", DefaultValue = 30)]
		[IntegerValidator(MinValue = 1, MaxValue = 1440, ExcludeRange = false)]
		public int FileCacheDurationInMinutes
		{
			get { return (int)this["fileCacheDurationInMinutes"]; }
			set { this["fileCacheDurationInMinutes"] = value; }
		}

		/// <summary>
		/// Interval of saving file cache registry to disk (in minutes)
		/// </summary>
		[ConfigurationProperty("fileCacheRegistrySaveIntervalInMinutes", DefaultValue = 1)]
		[IntegerValidator(MinValue = 1, MaxValue = 60, ExcludeRange = false)]
		public int FileCacheRegistrySaveIntervalInMinutes
		{
			get { return (int)this["fileCacheRegistrySaveIntervalInMinutes"]; }
			set { this["fileCacheRegistrySaveIntervalInMinutes"] = value; }
		}

		/// <summary>
		/// Enables sliding expiration time of file cache
		/// </summary>
		[ConfigurationProperty("useFileCacheSlidingExpiration", DefaultValue = true)]
		public bool UseFileCacheSlidingExpiration
		{
			get { return (bool)this["useFileCacheSlidingExpiration"]; }
			set { this["useFileCacheSlidingExpiration"] = value; }
		}
	}
}